<?php
/**
 * Created by JieHuiLong.
 * E-mail: jiehuilong@icloud.com
 * Date: 2016/8/16
 * Time: 16:00
 * 域名属性模型
 */
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App\Models\GroupAttributes as GroupAttr;

class DomainAttributes extends Model
{
    //为每个域名添加基础的扩展属性
    public function addBaseAttr($data)
    {
        //获取分组属性
        $groupAttrList = GroupAttr::where('gid', $data['gid'])->get();
        if (count($groupAttrList) > 0) {
            foreach ($groupAttrList as $key => $row) {
                $data['type'] = $row->type;
                $data['type_value'] = $row->type_value;
                $data['name'] = $row->name;
                $data['value'] = $row->value;
                $data['call_tag'] = $row->call_tag;
                $data['gaid'] = $row->id;
                $data['gid'] = $row->gid;
                $data['ganame'] = $row->gname;
                $newData[$key] = $data;
            }
            $this->insert($newData);
        }
    }
}
